package com.example.demo.domain.model;


import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class Parameter implements IParameter {
    private Long id;

    private String code;

    private String name;

    private String localName;

    private String description;

    private Date startDate;

    private Date endDate;

    private String parentCode;

    private Short hasChild;

    private String extendedDescription;

    private String security;

    private Long userid;

    private String operatorType;

    private Short autoCache;

    private Long currVersion;

    private Short removed;

    private Long parameterRootId;

    private String standardCode;

    private String sortType;

    private String userCode;

    private String chineseDescription;

    private Short showCode;

    private List<ParameterValue> parameterValues = new ArrayList<>();

    private List<ParameterDefinition> parameterDefinitions = new ArrayList<>();

    private String optType;

    @Override
    public void addParameterDefinition(ParameterDefinition parameterDefinition) {
        this.parameterDefinitions.add(parameterDefinition);
    }

    @Override
    public void setParameterDefinition(ParameterDefinition parameterDefinition) {
        this.parameterDefinitions.removeIf(x -> x.getId().equals(parameterDefinition.getId()));
        parameterDefinitions.add(parameterDefinition);
    }

    @Override
    public void addParameterValue(ParameterValue parameterValue) {
        this.parameterValues.add(parameterValue);
    }

    @Override
    public void setParameterValue(ParameterValue parameterValue) {
        this.parameterValues.removeIf(x -> x.getId().equals(parameterValue.getId()));
        this.parameterValues.add(parameterValue);

    }

}
